<?php defined( '_JEXEC') or die( 'Restricted access'); // No direct access ?>
    <div class="subhead">
        <fieldset>
            <legend>
                <h3>
                    Search volunteer:
                </h3>
            </legend>
            <p>
                <form name="form2" id="form2" method="post" action="<?php echo JRoute::_('index.php?option=com_volunteer&task=searchvolunteer') ;?>">
                    Name:
                    <input type="text" name="searchname" value="<?php echo JRequest::getVar('searchname');?>" />
                    <input type="submit" value="Search" />
					<input type="button" value="Show All volunteers" onClick="javascript:window.location='<?php echo JRoute::_('index.php?option=com_volunteer&view=searchvolunteer') ;?>';" />					
					<input type="button" value="Add new volunteer" onClick="javascript:window.location='<?php echo JRoute::_('index.php?option=com_volunteer&view=addvolunteer') ;?>';" />		
                </form>
            </p>
        </fieldset>
        <p>
            <h2>
                <?php if(JRequest::getVar('searchname')): ?> Search results:
                    <?php echo sizeof($this->results); ?> volunteer(s) found
                        <?php else: ?>
                            All volunteers:
                            <?php endif; ?>
            </h2>
        </p>
        <table border="1" cellspacing="0" width="100%">
            <tr align="center" bgcolor="#6cb33f">
                <td width="20%">
                    <strong>
                        Volunteer
                    </strong>
                </td>
                <td width="55%">
                    <p>
                        <strong>
                            Files uploaded
                        </strong>
                    </p>
                </td>
                <td width="25%">
                    <strong>Action</strong></a>
                </td>
            </tr>
			
<?php foreach($this->results as $volunteer): ?>
			<tr>
                <td>
                    <a href="<?php echo JRoute::_('index.php?option=com_volunteer&view=volunteerdetail&volunteer=' . $volunteer->username) ;?>"><?php echo $volunteer->username;?></a>
                </td>
                <td>
                    <p>
                        <?php echo $volunteer->totalFileUploaded;?>
						 
						<?php if($volunteer->totalFileUploaded > 0): ?>
                        <a href="<?php echo JRoute::_('index.php?option=com_volunteer&view=volunteerdetail&volunteer=' . $volunteer->username) ;?>">View files uploaded by <?php echo $volunteer->username;?></a>
						<?php endif; ?>
                    </p>
                </td>
                <td align="center">
                    <a href="<?php echo JRoute::_('index.php?option=com_volunteer&view=volunteerdetail&volunteer=' . $volunteer->username) ;?>">View</a>
                    &nbsp;
                    <a href="<?php echo JRoute::_('index.php?option=com_volunteer&view=editvolunteer&volunteer=' . $volunteer->username) ;?>">Edit</a>
                    &nbsp;
                    <a href="<?php echo JRoute::_('index.php?option=com_volunteer&task=deletevolunteer&volunteer=' . $volunteer->username) ;?>" onclick="javascript:confirm('Are you sure to delete volunteer <?php echo $volunteer->username;?>? This cannot be undone.')">Delete</a>
                </td>
            </tr>
<?php endforeach; ?>
        </table>
        <p>
            
        </p>
    </div>